unit StringUtils;

interface

uses StrUtils, Classes, SysUtils;

function StartWith(const SubStr, Str: String): Boolean;
function EndWith(const SubStr, Str: String): Boolean;
procedure SplitStr(const SrcString, SplitStr: String; var SpResult: TStrings;
  AllowEmpty: Boolean = True);

implementation

function StartWith(const SubStr, Str: String): Boolean;
begin
  Result := LeftStr(Str, Length(SubStr)) = SubStr;
end;

function EndWith(const SubStr, Str: String): Boolean;
begin
  Result := RightStr(Str, Length(SubStr)) = SubStr;
end;

procedure SplitStr(const SrcString, SplitStr: String; var SpResult: TStrings;
  AllowEmpty: Boolean = True);
var
  Index: Integer;
  MSrcString: String;
  FindStr: String;
begin
  MSrcString := SrcString;
  SpResult.Clear;
  Index := Pos(SplitStr, MSrcString);
  while Index > 0 do
  begin
    FindStr := LeftStr(MSrcString, Index - 1);
    if AllowEmpty or (Trim(FindStr) <> '') then
      SpResult.Add(FindStr);
    MSrcString := RightStr(MSrcString, Length(MSrcString) - (Index - 1) -
      Length(SplitStr));
    Index := Pos(SplitStr, MSrcString);
  end;
  if AllowEmpty or  (Trim(MSrcString) <> '') then
    SpResult.Add(MSrcString);
end;

end.
